package ru.teleology.cubefs.api.reflection.value;

import ru.teleology.cubefs.api.reflection.NativeType;
import ru.teleology.cubefs.api.reflection.Typed;
import ru.teleology.cubefs.api.reflection.Types;

@NativeType(name = Types.VALUE_TYPE)
public class Value extends  Typed{

	public Value(long handle, boolean weak) {
		super(handle, weak);
	}
	
	public Value(long handle) {
		super(handle, true);
	}
	
	void SetManaged(boolean managed) {
		SetManaged(getHandle(), managed);
	}

	boolean IsEquals(Value val) {
		return IsEquals(getHandle(), val != null ? val.getHandle() : 0);
	}
	
	public boolean equals(Object o) {
		return IsEquals((Value)o);
	}
	
	public void Set(Value other) {
		Set(getHandle(), other.getHandle());
	}
	
	@SuppressWarnings("unchecked")
	public <T> T toObject() {
		return (T)this;
	}
	
	private static native void Set(long me, long other);
	private static native void SetManaged(long me, boolean managed);
	private static native boolean IsEquals(long me, long val);
}
